
\chapter{Old stuff}
To identify how Accelerator can be used to optimize spreadsheets we did a prototype based on CoreCalc. In this chapter we describe the process, our choices and what limitations they give us. 

\subsection{Implementing Sheet Defined Functions}
A sheet defined function is described as ... by sestoft and it is implemented in CoreCalc. 
\todo{This should be described in background and be cited here}


\subsubsection{Parallel evaluating of multiple function calls at once}
As we concluded in section XX we need to either have a big amount of data or a complex/big graph of operations for Microsoft Accelerator to be able to optimize the operation. Therefore one need to have a quite complex sheet defined function for Accelerator being able to optimize the evaluation. 
However the same function is often used more than once and in simulations it's not uncommon for the same function to be used 1000+ times. If we build a single Accelerator graph for the entire call and evaluate all the function calls in parallel on the GPU we should expect increased performance. 

There's two obvious methods of implementing this. One is analyzing the spreadsheet support graph and identify possible parallel calls to the same functions, that doesn't depend on each other. The other method is using the built-in higher order Map like functions in CoreCalc. 

\subsubsection{Implementing parallel Map}
The built-in Map functions works by taking a function and a CellArea as arguments. The function is then evaluated once per Cell, using it as input for the the function. ColMap and RowMap call the function once per column/row and use the Cells on the opposite axis as input parameters.

In CoreCalc this is implemented with a nested For loop calling the method once per Cell/Row/Column, but in Accelerator we only want one call.  

As described above an AccNode has a GenerateFPA(float[,] input) method that generates the FPA graph that corresponds to the operation and input. When a function is called without using a Map function the input will only contain one row and therefore be in the form:

float[i,1] where i is the number of input paramters.

When the function is called using a Map function, each row will represent a new call to the same function. float[2,4] input array would indicate that the function is to be called 4 times and it has 2 input parameters.

If we have a sample function f=> input1+input2 it would give us this AccNode Structure: 
\todo{Graph thingie here!!!}
If we call it with map and take a look at the AccInput node with index 0, then it would return a FPA of float[1,3] where [0,0] is input0 for the first call and [0,1] is the first input of the second call. This will result in two FPA's of size 1,3 will have each element added and then a new 1,3 array will be returned. 

\textbf{Limitations in this design}\\
\todo{Definitely some!}

\subsubsection{Analyzing the graph}


\todo{ This should be new subsection:

- Finding the limit for when it makes sense\\ 
-- make overhead calculations for GPU \\
-- and CPU \\
-- Benchmark on startup 
}
-- Partial evaluation - what to evaluate when 
